/**
Copyright (c) 2008 Arnaud Fabre <arnaud333@gmail.com>
Copyright (c) 2008 Pierre "delroth" Bourdon <root@delroth.is-a-geek.org>

This file is part of Vos Tutos Offline.

Vos Tutos Offline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Vos Tutos Offline is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Vos Tutos Vos Tutos Offline.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _VTO_MAINWINDOW_H
#define _VTO_MAINWINDOW_H

#include <QMainWindow>
#include <QDockWidget>
#include <QCloseEvent>
#include <QStatusBar>

#include "global.h"
#include "menubar.h"
#include "nform.h"
#include "treeview.h"
#include "doc_part.h"
#include "doc_minitutorial.h"
#include "doc_bigtutorial.h"

class VTOMenuBar;

class VTOMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    VTOMainWindow(QWidget* parent = 0);
    ~VTOMainWindow();
    QDockWidget* getTutoTreeDock();
    NForm* getNForm();
    VTOMenuBar* getMenuBar();

public slots:
    void editionMode(TitledDocument* tuto, int tutotype);
	
    void editionPartChanged(QTreeWidgetItem* it, int col);
    void partTitleEditionRequest(QTreeWidgetItem* it, int col);


/* Nform slots */
    void licenceChange(int l);
    void progressChange(int p);
    void difficultChange(int d);
    void titleChange(QString t);

/* New Menu */
    void newNews();
    void newMiniTutorial();
    void newBigTutorial();
/* I/O Menu */
    void open();
    void save();
    void saveAs(QString fname = QString());
    
    void exportZcode();
    void exportLatex();
    
/* Inside a big tuto : */
    void newChapter();
    void newMinituto();
/* Inside a mini tuto */
    void newPart();
    
    void upSelected();
    void downSelected();
    void moveSelected(bool up);

    void removeSelected();

/* Option Menu */
	
    void latexconfig();

    // For close before new document or quit
    bool closeDocument();
    
    void documentWasModified();

protected:
    // Virtual reimplemented
    void closeEvent(QCloseEvent* event);

    void readSettings();
    void writeSettings();
	

    // GUI Methods 
    void initWidgets();
    void editionLayout();
    void clearLayout();

    void initToolBar();
   	
    /* Alerts */
    bool warning_closeDocument();
    
    // Attributes
    TitledDocument* tutorial;
    int tutorialtype;

/* The utility of Selected is when we have 
   many small tutorial in a big tutorial 
   so we need to know which is active */

    TitledDocument* docSelected;
    int docSelectedType;
    bool saved;

// Gui elements
    QStatusBar* statusBar;
    VTOMenuBar* vtoMenuBar;
    QDockWidget* tutotreeDock;
    TutoTree* tutotree;
    NForm* nForm;

};

#endif

